home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / bin / update.pl < prev   
Perl Script  |  2000-01-05  |  32KB  |  990 lines

  1. #!/usr/lab/bin/perl 
  2. # ------------------------------------------------------------
  3.  
  4. # update.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  5. # This allows the user to edit or create the _info file
  6. # necessary for the CDware.
  7. # version 1.0, Feb, 20 1996
  8. # ------------------------------------------------------------
  9.  
  10. # Bugs and other fixes
  11.  
  12. # ------------------------------------------------------------
  13. %GifImage = (
  14. "archive", "software.gif"
  15. ,"business", "software.gif"
  16. , "cad_cae", "software.gif"
  17. , "catalogs", "software.gif"
  18. , "client_server", "software.gif"
  19. , "desktop_apps", "software.gif"
  20. , "doc_mgt", "software.gif"
  21. , "epubs", "software.gif"
  22. , "graphics_imaging", "software.gif"
  23. , "info_mgt", "software.gif"
  24. , "multimedia", "software.gif"
  25. , "networking", "software.gif"
  26. , "security", "software.gif"
  27. , "sw_eng", "software.gif"
  28. , "sys_admin", "software.gif"
  29. , "telco", "software.gif"
  30. , "training", "software.gif"
  31. , "Hardware", "hardware.gif"
  32. , "Services", "services.gif"
  33. , "internet", "software.gif"
  34. , "Sun", "sunban.gif"
  35. #, "Info", "software.gif"
  36. , "companies", "companies.gif"
  37. );
  38.  
  39. %Categories = (
  40. "archive", "Archiving, Storage Management & Backup Solutions"
  41. ,"business", "Business Solutions"
  42. , "cad_cae", "CAD/CAE"
  43. , "catalogs", "Catalogs"
  44. , "client_server", "Client/Server Solutions"
  45. , "desktop_apps", "Desktop Applications"
  46. , "doc_mgt", "Document Management"
  47. , "epubs", "Electronic Publishing"
  48. , "graphics_imaging", "Graphics and Imaging"
  49. , "info_mgt", "Information Management"
  50. , "multimedia", "Multimedia"
  51. , "networking", "Networking"
  52. , "security", "Security"
  53. , "sw_eng", "Software Engineering"
  54. , "sys_admin", "System Administration"
  55. , "telco", "Telecommunications"
  56. , "training", "Training"
  57. , "Hardware", ""
  58. , "Services", ""
  59. , "internet", "Internet"
  60. , "Sun", ""
  61. #, "Info", "Info"
  62. , "companies", ""
  63. );
  64.  
  65. ##############################################################################
  66. # PrintHtml:
  67. ##############################################################################
  68. sub PrintHtml
  69. {
  70.     local($StrHtml1, $Str, $StrHtml2) = @_;
  71.     
  72.     if ($HTML_FORMAT eq "true") {
  73.         print STDOUT $StrHtml1;
  74.     }
  75.  
  76.     print STDOUT $Str;
  77.  
  78.     if ($HTML_FORMAT eq "true") {
  79.         print STDOUT $StrHtml2;
  80.     }
  81. }
  82. ##############################################################################
  83. # CheckLinks:
  84. ##############################################################################
  85. sub CheckLinks
  86. {
  87.     &PrintHtml("<BR>", "\nChecking links1...\n", "<BR>");
  88.     $ListDir = `cd $PRODUCTS_DIR; ls`;
  89.     $ListDir =~ s/gui|CDware|DEV|hotjava|tempjas|temp//g;
  90.     #$ListDir =~ s/\n+/ /g;
  91.     @dirfields = split(/\s+/, $ListDir);
  92.     foreach $Dir (@dirfields) {
  93.         if ($Dir =~ /CDware|DEV/) {
  94.             next;
  95.         }
  96.         &PrintHtml("<DD><DD>",  "\t\tTesting $Dir ...\n", "<BR>");
  97.         $ListFiles = `find "$PRODUCTS_DIR/$Dir" -name "*.html" -print`;
  98.         $ListFiles .= `find "$PRODUCTS_DIR/$Dir" -name "*.htm" -print`;
  99.         #$ListDir =~ s/gui|CDware|DEV|hotjava|tempjas|temp//g;
  100.         @filefields = split(/\s+/, $ListFiles);
  101.         foreach $File (@filefields) {
  102.             if ($File =~ /CDware.(frame|head).html/) {
  103.                 next;
  104.             }
  105.             #&PrintHtml("<DD><DD>",  "\t\tTesting $File ...\n", "<BR>");
  106.             if (open (HTMLFILE, $File)) {
  107.                 while(<HTMLFILE>) {
  108.                     chop;
  109.                     $Line = $_;
  110.                     $LinePrint = $Line;
  111.                     if ($HTML_FORMAT eq "true") {
  112.                         $LinePrint =~ s/</</g;
  113.                         $LinePrint =~ s/>/>/g;
  114.                     }
  115.                     if ($Line =~ /HREF/i) {
  116.                         $Ref = $Line;
  117.                         $Ref =~ s/.*HREF *= *"?([^" >#]*)[" >#].*/\1/i;
  118.                         if ($Ref =~ /HrefButtonArea/) {
  119.                             $Ref =~ s/.*HrefButtonArea,\d+,\d+,\d+,\d+,([^" >]*)/\1/;
  120.                         }
  121.                         #print "\t$Line\n\t->$Ref\n";
  122.                         if ($Ref eq $Line) {
  123.                             &PrintHtml("<B>",  "ERROR: Bug? in update.pl. File=$File\n", "</B><BR>");
  124.                             &PrintHtml("<DD>",  "\t$LinePrint\n\t->$Ref\n", "<BR>");
  125.                         }
  126.                         if ($Ref eq "" && $Line !~ /HREF *= *"?\#/i) {
  127.                             &PrintHtml("<B>",  "ERROR: Bug? in update.pl. File=$File\n", "</B><BR>");
  128.                             &PrintHtml("<DD>",  "\t$LinePrint\n\t->$Ref\n", "<BR>");
  129.                         }
  130.                         if ($Ref !~ /mailto:|ftp:|http:\/\/|req_more_info.pl/i || $Ref =~ /http:\/\/localhost/) {
  131.                         #if ($Ref !~ /mailto:|ftp:|http:\/\/[^l]|req_more_info.pl/i) {
  132.                             #print "->$Ref\n";
  133.                             $ShortDir = $File;
  134.                             $ShortDir =~ s?(.*\/)[^/]*$?\1?;
  135.                             if ($Ref =~ /http:\/\/localhost/i) {
  136.                                 $Ref =~ s?http://localhost:7999/(.*)$?$PRODUCTS_DIR/\1?;
  137.                                 #print "\t\tin http:$ShortDir/$Ref from $File\n";
  138.                                 if ($Ref !~ /cgi-bin/ && ! -s "$ShortDir/$Ref") {
  139.                                     &PrintHtml("<B>", "ERROR: Missing link $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  140.                                 }
  141.                             } elsif ($Ref =~ /file:/i) {
  142.                                 $Ref =~ s?file:///tmp/httpd/.products/(.*)$?$PRODUCTS_DIR/\1?;
  143.                                 #print "\t\tin file: $Ref from $File\n";
  144.                                 unless (-s "$Ref") {
  145.                                     &PrintHtml("<B>", "ERROR: Missing link $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  146.                                 }
  147.                             } else {
  148.                                 #print "\t\tin else: $ShortDir/$Ref from $File\n";
  149.                                 if ($Ref !~ /^#/) {
  150.                                     unless ($Ref !~ /^#/ && -s "$ShortDir/$Ref") {
  151.                                         &PrintHtml("<B>", "ERROR: Missing link $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  152.                                     }
  153.                                 }
  154.                             }
  155.                         }
  156.                         
  157.                     }
  158.                     if ($Line =~ /<IMG/i) {
  159.                         $Ref = $Line;
  160.                         $Ref =~ s/.*IMG.*SRC *= *"?([^" >]*)[" >].*/\1/i;
  161.                         #print "\t$Line\n\t->$Ref\n";
  162.                         if ($Ref eq $Line) {
  163.                             &PrintHtml("<B>",  "ERROR: Bug? in update.pl. File=$File\n", "</B><BR>");
  164.                             &PrintHtml("<DD>",  "\t$LinePrint\n\t->$Ref\n", "<BR>");
  165.                         }
  166.                         if ($Ref eq "") {
  167.                             &PrintHtml("<B>",  "ERROR: Bug? in update.pl. File=$File\n", "</B><BR>");
  168.                             &PrintHtml("<DD>",  "\t$LinePrint\n\t->$Ref\n", "<BR>");
  169.                         }
  170.                         #print "->$Ref\n";
  171.                         $ShortDir = $File;
  172.                         $ShortDir =~ s?(.*\/)[^/]*$?\1?;
  173.                         if ($Ref =~ /http:\/\/localhost/i) {
  174.                             $Ref =~ s?http://localhost:7999/(.*)$?$PRODUCTS_DIR/\1?;
  175.                             #print "\t\tin http:$ShortDir/$Ref from $File\n";
  176.                             if ($Ref !~ /cgi-bin/ && ! -s "$ShortDir/$Ref") {
  177.                                 &PrintHtml("<B>", "ERROR: Missing image $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  178.                             }
  179.                         } elsif ($Ref =~ /file:/i) {
  180.                             $Ref =~ s?file:///tmp/httpd/.products/(.*)$?$PRODUCTS_DIR/\1?;
  181.                             #print "\t\tin file: $Ref from $File\n";
  182.                             unless (-s "$Ref") {
  183.                                 &PrintHtml("<B>", "ERROR: Missing image $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  184.                             }
  185.                         } else {
  186.                             #print "\t\tin else: $ShortDir/$Ref from $File\n";
  187.                             if ($Ref !~ /^#/) {
  188.                                 unless ($Ref !~ /^#/ && -s "$ShortDir/$Ref") {
  189.                                     &PrintHtml("<B>", "ERROR: Missing image $Ref from $File. Line = $LinePrint\n", "</B><BR>");
  190.                                 }
  191.                             }
  192.                         }
  193.                         
  194.                     }
  195.                     #$Line =~ tr/
  196.                 }
  197.                 close(HTMLFILE);
  198.             } else {
  199.                 &PrintHtml("<B>",  "ERROR: $File cannot be open\n", "</B><BR>");
  200.             }
  201.         }
  202.     }
  203. }
  204. ##############################################################################
  205. # CheckFiles:
  206. ##############################################################################
  207. sub CheckFiles
  208. {
  209.     $ListDir = `cd $PRODUCTS_DIR; ls`;
  210.     $ListDir =~ s/gui|CDware|DEV|hotjava|tempjas|temp//g;
  211.     #$ListDir =~ s/\n+/ /g;
  212.     @filefields = split(/\s+/, $ListDir);
  213.     foreach $Dir (@filefields) {
  214.         unless (-s "$PRODUCTS_DIR/$Dir/_info") {
  215.             &PrintHtml("", "WARNING: _info file missing in $Dir\n", "<BR>");
  216.         }
  217.     }
  218.     #print $ListDir;
  219. }
  220.  
  221. ##############################################################################
  222. # InitCompInfo:
  223. ##############################################################################
  224. sub InitCompInfo
  225. {
  226.     $ListDir = `ls $PRODUCTS_DIR/*/_info`;
  227.     #print "ls $PRODUCTS_DIR/*/_info";
  228.  
  229.     @filefields = split(/\s+/, $ListDir);
  230.     #print $filefields;
  231.     foreach $INFOFILENAME (@filefields) {
  232.         $ShortDir = $INFOFILENAME;
  233.         $ShortDir =~ s?.*/([^/]*)/_info$?\1?;
  234.         if (-s $INFOFILENAME && open (INFOFILE, $INFOFILENAME)) {
  235.             if ($REPORT ne "true") {
  236.                 #&PrintHtml("<DD><DD>", "\t\tReading $INFOFILENAME\n", "<BR>");
  237.             }
  238.     
  239.                     while (<INFOFILE>) {
  240.                         $Line = $_;
  241.                 unless ($Line =~ /^[     ]*$/ || $Line =~ /^#/) {
  242.                     last;
  243.                 }
  244.             }
  245.                     ($Companies{$ShortDir}, $Description{$ShortDir}, $Platform{$ShortDir}, $ChosenCat{$ShortDir}, $WebSite{$ShortDir}, $Email{$ShortDir}, $HomePageName{$ShortDir}) = split(/\^/, $Line);
  246.  
  247.             if ($CHECK eq "true") {
  248.                 $_ = $Line;
  249.                 #print "Line=$Line\n";
  250.                 $count = tr/^//;
  251.                 #print "$_: $count\n";
  252.                 if ($count != 7) {
  253.                     &PrintHtml("<B>", "ERROR: Not the correct number of parameters in the first line of $INFOFILENAME\n", "<BR>");
  254.                 }
  255.                 if ($Platform{$ShortDir} =~ /demo|testdrive|install/ && ! -d "$PRODUCTS_DIR/$ShortDir/_install") {
  256.                     &PrintHtml("<B>", "ERROR: Missing _install directory in $ShortDir\n", "<BR>");
  257.                 }
  258.                 if ($HomePageName{$ShortDir} eq "") {
  259.                     &PrintHtml("<B>", "ERROR: Missing Home page name in $ShortDir\n", "<BR>");
  260.                 } else {
  261.                     unless (-s "$PRODUCTS_DIR/$ShortDir/$HomePageName{$ShortDir}") {
  262.                         &PrintHtml("<B>", "ERROR: $HomePageName{$ShortDir} file missing in $ShortDir\n", "<BR>");
  263.                     }
  264.                 }
  265.             }
  266.             $ProdNum = 1;
  267.                     while (<INFOFILE>) {
  268.                 if ($_ =~ /^[     ]*$/ || $_ =~ /^#/) {
  269.                     next;
  270.                 }
  271.                 if ($CHECK eq "true") {
  272.                     unless ($_ =~ /^.*[^     ].*\^$/) {
  273.                         chop($_);
  274.                         &PrintHtml("<B>", "ERROR: Wrong line in $INFOFILENAME: \"$_\"\n", "<BR>");
  275.                     }
  276.                 }
  277.                             $Product=$_;
  278.                             chop($Product);
  279.                             chop($Product);
  280.                             $Products{$ShortDir . $ProdNum} = $Product;
  281.                 #print "jp = $Product\n";
  282.                 $ProdNum++;
  283.                     }
  284.             close(INFOFILE);
  285.             } else {
  286.                     &PrintHtml("", "Can't open $INFOFILENAME\n", "<BR>");
  287.         }
  288.     }
  289.     #foreach $ShortDir (sort keys(%Companies)) {
  290.         #print "$Companies{$ShortDir}, $Description{$ShortDir}, $Platform{$ShortDir}, $ChosenCat{$ShortDir}, $WebSite{$ShortDir}, $Email{$ShortDir}, $HomePageName{$ShortDir}\n";
  291.     #}
  292.     #%RevComp = reverse %Companies;
  293.     #if (@RevComp != @Companies) {
  294.         #print "WARNING: two directory with the same company name->possible problem!\n";
  295.     #}
  296.     %RevProd = reverse %Products;
  297.     if (@RevProd != @Products) {
  298.         &PrintHtml("", "WARNING: two products with the same name->possible problem!\n", "<BR>");
  299.     }
  300.     #print @Products;
  301.     #foreach $ShortDir (sort keys(%Products)) {
  302.         #print "$ShortDir, $Products{$ShortDir}\n";
  303.     #}
  304.     #foreach $ShortDir (sort keys(%RevProd)) {
  305.         #print "$ShortDir, $RevProd{$ShortDir}\n";
  306.     #}
  307.     #foreach $ShortDir (sort keys(%RevComp)) {
  308.         #print "$RevComp{ShortDir}\n";
  309.     #}
  310.     #print %RevComp;
  311. }
  312.  
  313. sub FilteredSort
  314. {
  315.     ($al = $a) =~ tr/A-Z/a-z/;
  316.     $al =~ s/^the //;
  317.     $al =~ s/^[     ]*//;
  318.  
  319.     ($bl = $b) =~ tr/A-Z/a-z/;
  320.     $bl =~ s/^the //;
  321.     $bl =~ s/^[     ]*//;
  322.  
  323.     $al cmp $bl;
  324. }
  325. sub FilteredSortComp
  326. {
  327.     $al = $Companies{$a};
  328.     ($al = $a) =~ tr/A-Z/a-z/;
  329.     $al =~ s/^the //;
  330.     $al =~ s/^[     ]*//;
  331.  
  332.     $bl = $Companies{$b};
  333.     ($bl = $b) =~ tr/A-Z/a-z/;
  334.     $bl =~ s/^the //;
  335.     $bl =~ s/^[     ]*//;
  336.  
  337.     #print "$al =? $bl\n";
  338.     $al cmp $bl;
  339. }
  340.  
  341. ##############################################################################
  342. # CreateSoft
  343. ##############################################################################
  344. sub CreateSoft
  345. {
  346.     &PrintHtml("<BR>", "\nCreating Software page...\n", "<BR>");
  347.     $SOFTFILENAME = "$CAT_DIR/Software.html";
  348.     $SOFTHEADFILENAME = "$CAT_DIR/Software.head.html";
  349.     if (open (SOFTFILE, "> $SOFTFILENAME") && open(SOFTHEADFILE, "> $SOFTHEADFILENAME")) {
  350.         $old = select(SOFTHEADFILE);
  351.         $~ = "SOFTWAREHEAD"; 
  352.         write SOFTHEADFILE;   
  353.         close (SOFTHEADFILE); 
  354.  
  355.         select(SOFTFILE);
  356.         $~ = "CATBEGIN";
  357.         write SOFTFILE;
  358.  
  359.         $Letter = "0";
  360.         foreach $Cat (sort FilteredSort keys(%Categories)) {
  361.             unless ($Categories{$Cat} eq "") {
  362.                 $CatAb = $Categories{$Cat};
  363.                 $CatAb =~ tr/a-z/A-Z/;
  364.                 $CatAb =~ s/^THE //;
  365.                 #print STDOUT "$CatAb, $Letter\n";
  366.                 unless ($CatAb =~ /^$Letter/) {
  367.                     $Letter = substr($CatAb, 0, 1);
  368.                     print SOFTFILE "<DT><A NAME=\"$Letter\"><B>$Letter</B></A>";
  369.                     #push (@Letters, $Letter);
  370.                 }
  371.                 print SOFTFILE "<DD><a href=\"http://localhost:7999/.categories/?DEST=$Cat&SIZE=42\"><B>$Categories{$Cat}</B></a><br>\n";
  372.             }
  373.         }
  374.         $~ = "CATEND";
  375.         write SOFTFILE;
  376.  
  377.         close (SOFTFILE);
  378.         select($old);
  379.     }
  380.     &PrintHtml("<DD>", "\tSoftware.html page created.\n", "<BR>");
  381. }
  382.  
  383. ##############################################################################
  384. # CreateCat: 
  385. ##############################################################################
  386. sub CreateCat
  387. {
  388.     #system("mv $CAT_DIR/Software.html /tmp ");
  389.     #system("mv $CAT_DIR/companies.html /tmp >&/dev/null");
  390.     #system("mv $CAT_DIR/products.html /tmp >&/dev/null");
  391.     #system("rm $CAT_DIR/* >&/dev/null");
  392.     #system("mv /tmp/Software.html $CAT_DIR >&/dev/null");
  393.     #system("mv /tmp/companies.html $CAT_DIR >&/dev/null");
  394.     #system("mv /tmp/products.html $CAT_DIR >&/dev/null");
  395.  
  396.     foreach $catword  ( sort keys(%Categories)) {
  397.         #chop $catword;
  398.         &PrintHtml("<BR>", "\nCreating $catword category page ...\n", "<BR>");
  399.              $CATFILENAME = "$CAT_DIR/$catword.html";
  400.              $CATHEADFILENAME = "$CAT_DIR/$catword.head.html";
  401.         #print STDOUT "Bef open, $CATFILENAME, $CATHEADFILENAME\n";
  402.         if (open (CATFILE, "> $CATFILENAME") && open(CATHEADFILE, "> $CATHEADFILENAME")) {
  403.             $old = select(CATFILE);
  404.  
  405.             $~ = "CATBEGIN";
  406.             write CATFILE;
  407.             $Letter = "0";
  408.             @Letters = ();
  409.             #print STDOUT "Bef loop\n";
  410.             foreach $ShortName (sort FilteredSortComp keys(%Companies)) {
  411.                 $Comp = $Companies{$ShortName};
  412.                 #print STDOUT "        Comp=$Comp\n";
  413.                 #$ShortName = $RevComp{$Comp};    
  414.                 
  415.                 unless ($ChosenCat{$ShortName} =~ /$catword/ 
  416.                     || $catword eq "companies") {
  417.                     next;
  418.                 }
  419.                 $CompAb = $Comp;
  420.                 $CompAb =~ tr/a-z/A-Z/;
  421.                 $CompAb =~ s/^THE //;
  422.                 unless ($CompAb =~ /^$Letter/) {
  423.                     $Letter = substr($CompAb, 0, 1);
  424.                     print CATFILE "<DT><A NAME=\"$Letter\"><B>$Letter</B></A>";
  425.                     push (@Letters, $Letter);
  426.                 }
  427.  
  428.                     #print CATFILE "     <DD><a HREF=file:///tmp/httpd/.products/$ShortName/$HomePageName{$ShortName}><B>$Comp</B></a> $Description{$ShortName}\n";
  429.                     print CATFILE "     <DD><a HREF=file:///tmp/httpd/.products/$ShortName/$FRAMEBASICNAME><B>$Comp</B></a> $Description{$ShortName}\n";
  430.                     print "<dd><b><i>", $Products{$ShortName . "1"}, "</i></b>\n" ;
  431.                 if ($Products{$ShortName . "2"} ne "") {
  432.                         print ", <b><i>", $Products{$ShortName . "2"}, "</i></b>\n" ;
  433.                 }
  434.                 if ($Products{$ShortName . "3"} ne "") {
  435.                         print ", <b><i>", $Products{$ShortName . "3"}, "</i></b>\n" ;
  436.                 }
  437.                 }
  438.          
  439.         
  440.             $~ = "CATEND";
  441.             write CATFILE;
  442.             close (CATFILE);
  443.  
  444.             select(CATHEADFILE);
  445.             $~ = "CATHEADERBEGIN";
  446.             write CATHEADFILE;
  447.  
  448.         print CATHEADFILE "<param name=img value=\"$DIR_IMAGES/$GifImage{$catword}\">\n";
  449.         if ($catword ne "companies") {
  450.             print CATHEADFILE "<param name=area1 value=\"HrefButtonArea,27,4,69,40,?DEST=companies\">\n";
  451.         } else {
  452.             print CATHEADFILE "<param name=area1 value=\"HrefButtonArea,27,4,69,40,?DEST=Services\">\n";
  453.         }
  454.         print CATHEADFILE "<param name=area2 value=\"HrefButtonArea,27,36,69,90,?DEST=products\">\n";
  455.         if ($catword ne "Hardware") {
  456.             print CATHEADFILE "<param name=area3 value=\"HrefButtonArea,96,0,69,40,?DEST=Hardware\">\n";
  457.         } else {
  458.             print CATHEADFILE "<param name=area3 value=\"HrefButtonArea,96,0,69,40,?DEST=Software\">\n";
  459.         }
  460.         if ($catword ne "Services" && $catword ne "companies") {
  461.             print CATHEADFILE "<param name=area4 value=\"HrefButtonArea,96,38,69,74,?DEST=Services\">\n";
  462.         } else {
  463.             print CATHEADFILE "<param name=area4 value=\"HrefButtonArea,96,38,69,74,?DEST=Software\">\n";
  464.         }
  465.         print CATHEADFILE "<param name=area5 value=\"HrefButtonArea,200,0,395,74,../CDware/index.netscape.html\">\n";
  466.  
  467.         $~ = "CATHEADERMIDDLE";
  468.         write CATHEADFILE;
  469.  
  470.                 #print CATHEADFILE `cat $Header{$catword}`;
  471.             unless ($Categories{$catword} eq "") {
  472.                     print CATHEADFILE "<CENTER><FONT SIZE=24>$Categories{$catword}</FONT></CENTER>";
  473.             }
  474.     
  475.             #@Letters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
  476.             if (@Letters > 1) {
  477.                 print CATHEADFILE "<CENTER><B>Go to:  ";
  478.                 foreach $letter (@Letters) {
  479.                     print CATHEADFILE "<A HREF=\"?DEST=$catword&L=$letter" . ($Categories{$catword} eq ""? "" : "&SIZE=42") . "\">$letter</A>\n";
  480.                 }
  481.             }
  482.             $~ = "CATHEADEREND";
  483.             write CATHEADFILE;
  484.             close (CATHEADFILE);
  485.      
  486.             &PrintHtml("<DD>", "\t$catword category page created.\n", "<BR>");
  487.  
  488.             select($old);
  489.         } else {
  490.             die "\nERROR: Cannot write $CATFILENAME or $CATHEADFILENAME!\nTry to be superuser!\n\n";
  491.         }
  492.     }
  493. }
  494.  
  495. ##############################################################################
  496. # CreateReport:
  497. ##############################################################################
  498. sub CreateReport
  499. {
  500.     $TotalSize = 0;
  501.     foreach $ShortName (sort FilteredSortComp keys(%Companies)) {
  502.         #$ShortName = $RevComp{$Comp};    
  503.         $Comp = $Companies{$ShortName};
  504.         &PrintHtml("<B>", "$Comp:\n", "</B><BR>");
  505.         &PrintHtml("<DD>", "\tProduct1: " . $Products{$ShortName . "1"} . "\n", "<BR>");
  506.         if ($Products{$ShortName . "2"} ne "") {
  507.             &PrintHtml("<DD>", "\tProduct2: " . $Products{$ShortName . "2"} . "\n", "<BR>");
  508.         }
  509.         if ($Products{$ShortName . "3"} ne "") {
  510.             &PrintHtml("<DD>", "\tProduct3: " . $Products{$ShortName . "3"} . "\n", "<BR>");
  511.         }
  512.         $Size = `du -ks $PRODUCTS_DIR/$ShortName`;
  513.         chop $Size;
  514.         $Size =~ s/(\d*).*/\1/;
  515.         &PrintHtml("<DD>", "\tTotal size: $Size Kb\n", "<BR>");
  516.         $TotalSize += $Size;
  517.         if ( $Platform{$ShortName} =~ /demo|testdrive|install/) {
  518.             &PrintHtml("<DD>", "\t", "");
  519.             if ($Platform{$ShortName} =~ /demo/) {
  520.                 &PrintHtml("", "Slide-show, ", "");
  521.             }
  522.             if ($Platform{$ShortName} =~ /testdrive/) {
  523.                 &PrintHtml("", "Demo version, ", "");
  524.             }
  525.             if ($Platform{$ShortName} =~ /install/) {
  526.                 &PrintHtml("", "Unlockable version, ", "");
  527.             }
  528.             &PrintHtml("", "\n", "<BR>");
  529.         }
  530.     }
  531.     &PrintHtml("<BR><BR>", "\n\nTotal size for all companies: $TotalSize Kb\n", "<BR>");
  532.     $Size = `du -ks $PRODUCTS_DIR/$ShortName`;
  533.     chop $Size;
  534.     $Size =~ s/(\d*).*/\1/;
  535.     &PrintHtml("", "Total size for .products: $Size Kb\n", "<BR>");
  536. }
  537.  
  538. ##############################################################################
  539. # CreateApplet:
  540. ##############################################################################
  541. sub CreateApplet
  542. {
  543.     &PrintHtml("", "\nBuilding Control bar applets ...\n", "<BR>");
  544.     $TmpFile = "/tmp/tmpupdateapplet";
  545.     foreach $Comp (sort keys(%Companies)) {
  546.         $FRAMEFILENAME = "$PRODUCTS_DIR/$Comp/$FRAMEBASICNAME";
  547.         if (open (FRAMEFILE, "> $FRAMEFILENAME")) {
  548.             print FRAMEFILE "<html> <head>\n<title>CDware May 1996: $Companies{$Comp}</title>\n</head>\n<FRAMESET ROWS=\"50,*\">\n<FRAME SCROLLING=\"no\" TARGET=\"_top\" NAME=\"menu\" NORESIZE SRC=\"CDware.head.html\">\n<FRAME SCROLLING=\"yes\" NAME=\"content\" NORESIZE MARGINHEIGHT=4 SRC=\"$HomePageName{$Comp}\">\n</BODY> </NOFRAME> </FRAMESET> </HTML>\n";
  549.             close(FRAMEFILE);
  550.         } else {
  551.             &PrintHtml("", "ERROR: Couldn't write $FRAMEFILENAME\n", "<BR>");
  552.         }
  553.  
  554.         $HEADFILENAME = "$PRODUCTS_DIR/$Comp/$HEADBASICNAME";
  555.         if (open (HEADFILE, "> $HEADFILENAME")) {
  556.             print HEADFILE "<html> <head>\n<title>CDware May 1996</title>\n</head>\n<BODY>\n<CENTER>\n<applet code=ImageMap.class width=596 height=36>\n<param name=highlight value=\"brighter60\">";
  557.             
  558.             $TestGif = 0;
  559.             if ($Platform{$Comp} =~ /demo/) {
  560.                 $TestGif ++;
  561.             }
  562.             if ($Platform{$Comp} =~ /testdrive/) {
  563.                 $TestGif += 2;
  564.             }
  565.             if ($Platform{$Comp} =~ /install/) {
  566.                 $TestGif += 4;
  567.             }
  568.             @BarFileNames = ("none", "rd", "td", "tdrd", "ts", "tsrd", "tdts", "samplebar");
  569.             print HEADFILE "<param name=img value=\"$PRODUCTS_DIR/CDware/images/$BarFileNames[$TestGif].gif\">\n";
  570.  
  571.             print HEADFILE "<param name=area1 value=\"HrefButtonArea,0,0,80,35,file:///tmp/httpd/.products/CDware/index.netscape.html\" >\n";
  572.             print HEADFILE "<param name=area2 value=\"HrefButtonArea,81,0,84,35,http://localhost:7999/.categories/?DEST=companies\" >\n";
  573.             print HEADFILE "<param name=area3 value=\"HrefButtonArea,164,0,83,35,file:///tmp/httpd/.products/CDware/docs/info/features.html\" >\n";
  574.             print HEADFILE "<param name=area4 value=\"HrefButtonArea,267,0,85,35,http://localhost:7999/cgi-bin/req_more_info.pl?$Comp\" >\n";
  575.  
  576.             $Area = 5;
  577.             if ($Platform{$Comp} =~ /demo/) {
  578.                 print HEADFILE "<param name=area$Area value=\"HrefButtonArea,350,0,83,35,http://localhost:7999/$Comp/_install/install_show.sh\">\n";
  579.                 $Area ++;
  580.             }
  581.             if ($Platform{$Comp} =~ /testdrive/) {
  582.                 print HEADFILE "<param name=area$Area value=\"HrefButtonArea,434,0,81,35,http://localhost:7999/$Comp/_install/run.sh\">\n";
  583.                 $Area ++;
  584.             }
  585.             if ($Platform{$Comp} =~ /install/) {
  586.                 print HEADFILE "<param name=area$Area value=\"HrefButtonArea,515,0,83,35,http://localhost:7999/$Comp/_install/install.sh\">\n";
  587.             }
  588.             
  589.             print HEADFILE "</applet> </CENTER> </BODY> </HTML>\n";
  590.  
  591.  
  592.             close(HEADFILE);
  593.         } else {
  594.             &PrintHtml("", "ERROR: Couldn't write $HEADFILENAME\n", "<BR>");
  595.         }
  596.  
  597.              #$HOMEFILENAME = "../$Comp/" . $HomePageName{$ShortDir};
  598.         #if (open (HOMEFILE, "$HOMEFILENAME")) {
  599.             #open (TMPFILE, "$TmpFile");
  600.             #while (<TMPFILE>) {
  601.                 #$Line = $_;
  602.                 #if ($Line =~ /^<applet class=cdbar/i) {
  603.                     #while (! <HOMEFILE> =~ /^<\/applet>/i) {
  604.                     #}
  605.                     #$TestGif = 0;
  606.                     #if ($Platform{$Comp} =~ /demo/) {
  607.                         #$TestGif ++;
  608.                     #}
  609.                     #if ($Platform{$Comp} =~ /testdrive/) {
  610.                         #$TestGif ++;
  611.                     #}
  612.                     #if ($Platform{$Comp} =~ /install/) {
  613.                         #$TestGif ++;
  614.                     #}
  615.                     #print TMPFILE "<app class=CDbar img=\"../CDware/images/none.gif";
  616.                     #print TMPFILE "highlight=brighter60";
  617. ##            print "area1=HrefButtonArea,0,0,80,35,file:///tmp/httpd/.products/CDware/index.html" >> applet
  618. ##            print "area2=HrefButtonArea,81,0,84,35,file:///tmp/httpd/.products/.categories/companies.html" >> applet
  619. ##            print "area3=HrefButtonArea,164,0,83,35,file:///tmp/httpd/.products/CDware/docs/info/features.html" >> applet
  620. ##            print "area4=HrefButtonArea,267,0,85,35,file:///tmp/httpd/.products/DEV/disabled.html" >> applet
  621. ##            print ">" >> applet
  622. ##                        breaksw    
  623. ## 
  624.                     #next;
  625.                 #}
  626.                 #print TMPFILE $Line;
  627.             #}
  628.         #}
  629.         #rename($TmpFile, $HOMEFILENAME);
  630.     }
  631.     &PrintHtml("", "\tControl bar applets built...\n", "<BR>");
  632. }
  633. ###############################################################################
  634. ## CreateProduct
  635. ###############################################################################
  636. sub CreateProduct
  637. {
  638.     &PrintHtml("<BR>", "\nCreating Products page...\n", "<BR>");
  639.  
  640.          $PRODFILENAME = "$CAT_DIR/products.html";
  641.          $PRODHEADFILENAME = "$CAT_DIR/products.head.html";
  642.     if (open (PRODFILE, "> $PRODFILENAME") && open(PRODHEADFILE, "> $PRODHEADFILENAME")) {
  643.         $old = select(PRODFILE);
  644.  
  645.         $~ = "CATBEGIN";
  646.         write PRODFILE;
  647.         $Letter = "0";
  648.         @Letters = ();
  649.         foreach $Prod (sort FilteredSort keys(%RevProd)) {
  650.             $ShortName = substr($RevProd{$Prod}, 0, length($RevProd{$Prod}) - 1);    
  651.             
  652.             #print STDOUT "        Prod=$Prod, ShortName=$ShortName.\n";
  653.             $ProdAb = $Prod;
  654.             $ProdAb =~ tr/a-z/A-Z/;
  655.             $ProdAb =~ s/^THE //;
  656.             $ProdAb =~ s/^[     ]*//;
  657.             unless ($ProdAb =~ /^$Letter/) {
  658.                 $Letter = substr($ProdAb, 0, 1);
  659.                 print PRODFILE "<DT><A NAME=\"$Letter\"><B>$Letter</B></A>";
  660.                 push (@Letters, $Letter);
  661.             }
  662.  
  663.                 #print PRODFILE "<DD><A HREF=file:///tmp/httpd/.products/$ShortName/$HomePageName{$ShortName}><B>$Prod</B></A> <I>from</I> <B>$Companies{$ShortName}</B>\n";
  664.                 print PRODFILE "<DD><A HREF=file:///tmp/httpd/.products/$ShortName/$FRAMEBASICNAME><B>$Prod</B></A> <I>from</I> <B>$Companies{$ShortName}</B>\n";
  665.             }
  666.      
  667.         $~ = "CATEND";
  668.         write PRODFILE;
  669.         close (PRODFILE);
  670.  
  671.         select(PRODHEADFILE);
  672.         $~ = "CATHEADERBEGIN";
  673.         write PRODHEADFILE;
  674.  
  675.         print PRODHEADFILE "<param name=img value=\"$DIR_IMAGES/products.gif\">\n";
  676.         print PRODHEADFILE "<param name=area1 value=\"HrefButtonArea,27,4,69,40,?DEST=companies\">\n";
  677.         print PRODHEADFILE "<param name=area2 value=\"HrefButtonArea,27,36,69,90,?DEST=Services\">\n";
  678.         print PRODHEADFILE "<param name=area3 value=\"HrefButtonArea,96,0,69,40,?DEST=Hardware\">\n";
  679.         print PRODHEADFILE "<param name=area4 value=\"HrefButtonArea,96,38,69,74,?DEST=Software\">\n";
  680.         print CATHEADFILE "<param name=area5 value=\"HrefButtonArea,200,0,395,74,../CDware/index.netscape.html\">\n";
  681.  
  682.         print PRODHEADFILE "</applet><br></td><tr><td>";
  683.         #$~ = "CATHEADERMIDDLE";
  684.         #write PRODHEADFILE;
  685.  
  686.             #print PRODHEADFILE `cat $Header{$catword}`;
  687.         #unless ($Categories{$catword} eq "") {
  688.                 #print PRODHEADFILE "<H1>$Categories{$catword}</H1>";
  689.         #}
  690.  
  691.         #@Letters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
  692.         print PRODHEADFILE "<B><FONT size=\"4\"> Go to:\n";
  693.         foreach $letter (@Letters) {
  694. # below changed by Marc
  695.             #print PRODHEADFILE "<A HREF=\"?DEST=$catword&L=$letter\">$letter</A>\n";
  696.             print PRODHEADFILE "<A HREF=\"?DEST=products&L=$letter\">$letter</A>\n";
  697.         }
  698.         $~ = "CATHEADEREND";
  699.         write PRODHEADFILE;
  700.         close (PRODHEADFILE);
  701.  
  702.         &PrintHtml("<DD>", "\tproducts.html page created.\n", "<BR>");
  703.  
  704.         select($old);
  705.     }
  706. }
  707. ##############################################################################
  708. # MAIN PART: Decode the parameters and calls the correct subfunctions
  709. ##############################################################################
  710. #$arg0=$0
  711. #$DIR=$arg0:h
  712. #$ProgName=$arg0:t
  713.  
  714. #if ("X$DIR" == "X$ProgName") {
  715.     #$DIR='.'
  716. #}
  717.  
  718. #if (-e "./$ProgName") {
  719.     #$DIR=$cwd
  720. #}
  721.  
  722. #cd  $DIR
  723. #print `pwd`;
  724.  
  725. #
  726. # Create the category pages seen in the categories.txt file
  727. #
  728.  
  729. #foreach $en (sort keys %ENV) {
  730.     #print "$en = $ENV{$en}\n";
  731. #}
  732.  
  733.  
  734.     $CATS = "false";
  735.     $APPLETS = "false";
  736.     $COMP = "false";
  737.     $CHECK = "false";
  738.     $REPORT = "false";
  739.     $HTML_FORMAT = "false";
  740.     $PROD = "false";
  741.     $SOFT = "false";
  742.     $PLATFORM = "sparc";
  743.  
  744.     $DIR_IMAGES = "../CDware/images/";
  745.     $PRODUCTS_DIR = "../";
  746.  
  747.     # parse command line arguements
  748.  
  749.     #print "Arg=@ARGV.\n";
  750.     @ARGREPORT = @ARGV;
  751.     if (@ARGV == 0) {
  752.         @ARGV=("-?");
  753.     }
  754.  
  755.         while ($ARGV[0] =~ /^-/) {
  756.             $_ = shift;
  757.             #print "Arg=$_.\n";
  758.             if (/^-cats$/) {
  759.                 $CATS = "true";
  760.             } elsif (/^-applets/) {
  761.                 $APPLETS = "true";
  762.             } elsif (/^-comp/) {
  763.                 $COMP = "true";
  764.             } elsif (/^-checkall/) {
  765.                 $CHECK = "true";
  766.                 $CHECKLINKS = "true";
  767.             } elsif (/^-checklinks/) {
  768.                 $CHECKLINKS = "true";
  769.             } elsif (/^-check/) {
  770.                 $CHECK = "true";
  771.             } elsif (/^-soft/) {
  772.                 $SOFT = "true";
  773.             } elsif (/^-report/) {
  774.                 $REPORT = "true";
  775.             } elsif (/^-html/) {
  776.                 $HTML_FORMAT = "true";
  777.             } elsif (/^-dir/) {
  778.                 $PRODUCTS_DIR = ($1 ? $1 : shift);
  779.                 unless (-s $PRODUCTS_DIR) {
  780.                     die "ERROR: $PRODUCTS_DIR is not a directory\n";
  781.                 }
  782.             } elsif (/^-prod/) {
  783.                 $PROD = "true";
  784.             } elsif (/^-all/) {
  785.                 $PROD = "true" ;
  786.                 $COMP = "true";
  787.                 $SOFT = "true";
  788.                 $APPLETS = "true";
  789.                 $CATS = "true";
  790.             } elsif (/^-x86/) {
  791.                 $PLATFORM = x86;
  792.                 $SRC_DIR = "../../../x86.image";
  793.             } elsif (/^-[?Hh]/) {
  794.                 die "Usage: update.pl [ -cats | -applets | -soft | -prod | -all | -dir dirname | -x86  | -report | -html | -check]\n\tall: = -cats -prod -applets\n\tapplets: creates an applet in the customer home page.\n\tcats: creates the category and company pages.\n\tcheck: check the _info file, and other things for errors.\n\tdir: gives the directory where the companies are located.\n\thtml: when -report is selected, creates an output in HTML format.\n\tprod: creates the product page.\n\treport: creates a report for all companies.\n\tsoft: creates the Software pages\n\tx86: for future usage.\n";
  795.             } else {
  796.                 die "Unrecognized switch: $_ (try -?)\n";
  797.             }
  798.         }
  799.  
  800. &PrintHtml("<HTML> <HEAD> <title>Catalyst CDware - status on " . `date` . "</title> </HEAD> <BODY><H1>", "Catalyst CDware - status on " . `date` . "\n", "</H1>");
  801.  
  802. # check if root user
  803. if ( $ENV{"USER"} ne "root" ) {
  804.         &PrintHtml("", "WARNING: This program should be run as root user.\n", "<BR>");
  805.     }
  806.  
  807.  
  808.     if ($REPORT ne "true") {
  809.         $HostName = `hostname`;
  810.         chop $HostName;
  811.         &PrintHtml("", "\nUpdating CDware on $HostName:\n\n", "<BR>");
  812.     if (open (REPORTFILE, ">> $PRODUCTS_DIR/.update.txt")) {
  813.         $Date = `date`;
  814.         chop $Date;
  815.         print REPORTFILE "update by " . $ENV{"USER"} . " on $Date from $HostName\n\tparams: ";
  816.         while (@ARGREPORT) {
  817.             print REPORTFILE "$ARGREPORT[0], ";
  818.             shift @ARGREPORT;
  819.         }
  820.         print REPORTFILE "\n\n";
  821.         close (REPORTFILE);
  822.     } else {
  823.         &PrintHtml("", "WARNING: Cannot open $PRODUCTS_DIR/.update.txt\n", "<BR>");
  824.     }
  825. }
  826.  
  827. &InitCompInfo();
  828.  
  829. $CAT_DIR = "$PRODUCTS_DIR/.categories";
  830. $FRAMEBASICNAME = "CDware.frame.html";
  831. $HEADBASICNAME = "CDware.head.html";
  832. #print $CAT_DIR;
  833. if ( ! -d $CAT_DIR ) {
  834.     mkdir($CAT_DIR, 0777);
  835. }
  836.  
  837. if ( $CHECK eq "true" ) {
  838.     &CheckFiles();
  839. }
  840.  
  841. if ( $CHECKLINKS eq "true" ) {
  842.     &CheckLinks();
  843. }
  844.  
  845. if ( $CATS eq "true" ) {
  846.     &CreateCat();
  847. }
  848.  
  849. if ( $SOFT eq "true" ) {
  850.     &CreateSoft();
  851. }
  852.  
  853. #
  854. # Get all CDware menu bar components and put in file 
  855. # for building of front page applet 
  856. #
  857. if ( $APPLETS eq "true" ) {
  858.     &CreateApplet();
  859. }
  860.  
  861. if ( $PROD eq "true" ) {
  862.     &CreateProduct();
  863. }
  864.  
  865. if ( $REPORT eq "true" ) {
  866.     &CreateReport();
  867. }
  868.  
  869. #
  870. # Compile list of companies, place in 'companies' file
  871. #
  872. #if ( $COMP eq "true" ) {
  873.     #&CreateComp();
  874. #}
  875.  
  876. #
  877. # Compile list of products, place in 'products' file
  878. #
  879.  
  880. #print "\n\n\nPress <RETURN> to close the window and test your submission..\n.";
  881. #read answer;
  882.  
  883. ################################################################################
  884. # Define FORMATS (no more code)
  885. ################################################################################
  886. format CATHEADERBEGIN =
  887. <html>
  888. <body  BGCOLOR="#8c8cde" link=#33ff00 vlink=#33ff00 >
  889. <center>
  890. <BASE TARGET="_top" HREF="http://localhost:7999/.categories/">
  891. <form method="get"  ACTION="http://localhost:7999/cgi-bin/brandnewwais.pl/wais_CDware">
  892. <table border = 9><td>
  893. <applet code=ImageMap.class width=596 height=75>
  894. <param name=highlight value="brighter60">
  895. .
  896.  
  897. format CATHEADERMIDDLE =
  898. </applet><br></td><tr><td>
  899. <B><FONT size="4">
  900. #<B>Go to:  </b>
  901. .
  902.  
  903. format CATHEADEREND =
  904. </font>
  905.  Search: <input type="text" name="isindex" size="12" >
  906. </CENTER>
  907. </td><tr></table>
  908. </form>
  909. </center>
  910. </body>
  911. </html>
  912. .
  913.  
  914. format CATBEGIN =
  915. <HTML>
  916.         <!-- header section-->
  917. <HEAD>
  918. <title>Catalyst CDware - SPARC Edition - January through April</title>
  919. </HEAD>
  920.         <!-- document body-->
  921. <BODY>
  922. <BASE TARGET="_top">
  923. <DL>
  924. #<hr>
  925. #<p>
  926. .
  927.  
  928. format CATEND =
  929. </B></B><DT>
  930. <hr>
  931. </BODY>
  932. </HTML>
  933. .
  934.  
  935. format SOFTWAREHEAD =
  936. <HTML>
  937.         <!-- header section-->
  938. <HEAD>
  939. <TITLE>Catalyst CDware - Software Categories</TITLE>
  940. </HEAD>
  941.         <!-- document body-->
  942. <BODY BGCOLOR="8c8cde" link=#33ff00 vlink=#33ff00>
  943. <CENTER>
  944. <BASE TARGET="_top" HREF="http://localhost:7999/.categories/">
  945. <form method="get"  ACTION="http://localhost:7999/cgi-bin/brandnewwais.pl/wais_CDware">
  946. <table border = 9><td>
  947. <applet code=ImageMap.class width=596 height=75>
  948. <param name=highlight value="brighter60">
  949. <param name=img value="../CDware/images/software.gif">
  950. <param name=area1 value="HrefButtonArea,27,4,69,40,../.categories/?DEST=companies">
  951. <param name=area2 value="HrefButtonArea,27,36,69,90,../.categories/?DEST=products">
  952. <param name=area3 value="HrefButtonArea,96,0,69,40,../.categories/?DEST=Hardware">
  953. <param name=area4 value="HrefButtonArea,96,38,69,74,../.categories/?DEST=Services">
  954. <param name=area5 value="HrefButtonArea,200,0,395,74,../CDware/index.netscape.html">
  955. </applet>
  956. </TD><TR><TD>
  957. <CENTER>
  958. Search: <input type="text" name="isindex" size="12" >
  959. </CENTER>
  960. </td><tr></table>
  961. </CENTER>
  962. </form>
  963. </BODY>
  964. </HTML>
  965. .
  966. ##############################################################################
  967. format FRAMEHEADER =
  968. Content-type: text/html
  969.  
  970.  
  971.  
  972. <html>
  973. <head>
  974. <title>CDware May 1996</title>
  975. </head>
  976. <FRAMESET ROWS="20,80">
  977. #$size
  978. .
  979. ##############################################################################
  980. format FRAMEFOOTER =
  981. <BODY BACKGROUND="icons/bkgrnds/homebg.gif" body bgcolor=black text=#ffffff link=#dddddd alink=#ffff00 vlink=#bbbbbb>
  982.  
  983. <FONT SIZE=-1>Copyright \0511995 <B><A
  984.  
  985. </BODY>
  986. </NOFRAME>
  987. </FRAMESET>
  988. </HTML>
  989. .
  990.